package com.cyjt.operation.bean;

import java.util.Date;

import com.cyjt.operation.base.Tools;

/**
 * 动态节点列表实体类
 * 
 * @author LTP
 *
 */
public class DynamicNodesStatusInfo implements Comparable<DynamicNodesStatusInfo> {
	/** 基站编码 */
	private String basestationCode;
	/** 节点编号 */
	private int nfcCode;
	/** 节点所在路段 */
	private String title;
	/** 节点最新心跳时间时间 */
	private Date submitAt;
	/** 节点状态 */
	private int status;
	/** 节点位置 */
	private String crossing;
	/** 车道 */
	private int driveway;

	/**
	 * @return 基站编码
	 */
	public String getBasestationCode() {
		return basestationCode;
	}

	public void setBasestationCode(String basestationCode) {
		this.basestationCode = basestationCode;
	}

	/**
	 * @return 节点编号
	 */
	public int getNfcCode() {
		return nfcCode;
	}

	public void setNfcCode(int nfcCode) {
		this.nfcCode = nfcCode;
	}

	/**
	 * @return 节点所在路段
	 */
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @return 节点最新心跳时间
	 */
	public Date getSubmitAt() {
		return submitAt;
	}

	/**
	 * @return 节点最新心跳时间
	 */
	public String getSubmitAtString() {
		if (getSubmitAt() == null) {
			return Tools.getDF(new Date()).toString();
		}
		return Tools.getDF(getSubmitAt()).toString();
	}

	/**
	 * 获得最后心跳与目前的间隔时间
	 * 
	 * @return 间隔时间
	 */
	public String getTimeFromNow() {
		if (getSubmitAt() != null) {
			String s = Tools.diffTime(getSubmitAt(), new Date());
			if (s.equals("")) {
				return "刚刚";
			}
			return Tools.diffTime(getSubmitAt(), new Date()) + "前";
		}
		return "无提交时间";
	}

	public void setSubmitAt(Date submitAt) {
		this.submitAt = submitAt;
	}

	public int getStatus() {
		return status;
	}

	/**
	 * 节点状态信息
	 * 
	 * @return 正常或异常
	 */
	public String getStatusToString() {
		if (status == 1) {
			return "正常";
		}
		return "异常";
	}

	public void setStatus(int status) {
		this.status = status;
	}

	/**
	 * @return 节点位置
	 */
	public String getCrossing() {
		return crossing;
	}

	public void setCrossing(String crossing) {
		this.crossing = crossing;
	}

	/**
	 * @return 车道
	 */
	public int getDriveway() {
		return driveway;
	}

	public void setDriveway(int driveway) {
		this.driveway = driveway;
	}

	@Override
	public int compareTo(DynamicNodesStatusInfo another) {
		// TODO Auto-generated method stub
		return this.nfcCode - another.nfcCode;
	}

}
